package com.xxx.test;

import com.xxx.DAO.user_bookDao;
import com.xxx.entity.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/showBorrow")
public class showBorrow extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int uid= (int) request.getSession().getAttribute("id");
        user_bookDao dao=new user_bookDao();
        List<Book> borrowedBooks;
        borrowedBooks=dao.findBorrow(uid);
        request.setAttribute("list",borrowedBooks);
        //跳转页面
        request.getRequestDispatcher("person.jsp").forward(request,response);
    }
}
